<?php

declare(strict_types=1);

namespace App\Fastapp\Model;

use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\Database\Model\SoftDeletes;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property string $deleted_at 删除时间
 * @property array $title 标题
 * @property array $subtitle 副标题
 * @property string $author 作者
 * @property array $cover 封面
 * @property array $video 视频
 * @property string $video_duration 视频时长
 * @property string $release_at 发布日期
 * @property array $brief 摘要
 * @property array $content 内容
 * @property string $remark 备注
 * @property int $sort 排序
 * @property int $critique 评论数
 * @property int $views 浏览数
 * @property int $like 点赞数
 * @property int $status 1显示
 * @property string $code 调用代码
 * @property int $account_type
 */
class FastappArticle extends MineModel
{
    use SoftDeletes, FileTrait;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'fastapp_article';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'created_at', 'updated_at', 'deleted_at', 'title', 'subtitle', 'author', 'cover', 'video', 'video_duration', 'release_at', 'brief', 'content', 'remark', 'sort', 'critique', 'views', 'like', 'status', 'code', 'account_type'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'title' => 'array', 'subtitle' => 'array', 'cover' => 'array', 'video' => 'array', 'brief' => 'array', 'content' => 'array', 'sort' => 'integer', 'critique' => 'integer', 'views' => 'integer', 'like' => 'integer', 'status' => 'integer', 'account_type' => 'integer'];

    public function categoryArticle(): HasMany
    {
        return $this->hasMany(FastappCategoryArticle::class, 'article_id', 'id');
    }
    public function categoryTag(): HasMany
    {
        return $this->hasMany(FastappTagArticle::class, 'article_id', 'id');
    }
}
